<template>
  <div class="app-container">
    <el-card shadow="never" v-loading="loading">
      <el-row :gutter="5">
        <el-col :span="24" class="main-card-view">
          <el-row>
            <el-card shadow="never" class="top-search-view-card">
              <el-row>
                <el-form :inline="true" :model="searchForm" class="demo-form-inline search-view">
                  <el-form-item label="专家名称">
                    <el-input v-model="searchForm.name" placeholder="请输入专家名称"></el-input>
                  </el-form-item>
                  <el-form-item label="机构名称">
                    <el-input v-model="searchForm.organName" placeholder="请输入机构名称"></el-input>
                  </el-form-item>
                  <el-form-item label="科室">
                    <el-input v-model="searchForm.departmentName" placeholder="请输入科室"></el-input>
                  </el-form-item>
                  <el-form-item label="属地">
                    <el-select style="width: 100%;" v-model="searchForm.dependency">
                      <el-option v-for="(item, index) in ['省级', '市级', '区县级']" :key="index" :label="item" :value="item" />
                    </el-select>
                  </el-form-item>
                  <el-form-item>
                    <el-button type="primary" @click="handleSearch" class="search-button">查询</el-button>
                  </el-form-item>
                </el-form>
              </el-row>
            </el-card>
          </el-row>
          <el-row>
            <el-card shadow="never">
              <el-table :data="tableData" :stripe="true" style="width: 100%">
                <el-table-column prop="personalImg" align="center" label="图片">
                  <template slot-scope="scope">
                    <el-image :src="scope.row.personalImg" style="width: 50px;height: 50px;" />
                  </template>
                </el-table-column>
                <el-table-column prop="name" align="center" label="专家名称" />
                <el-table-column prop="organName" align="center" label="机构名称" />
                <el-table-column prop="departmentName" align="center" label="科室" />
                <el-table-column prop="position" align="center" label="职称" />
                <el-table-column prop="officePhone" align="center" label="电话" />
                <el-table-column align="center" label="操作" width="200">
                  <template slot-scope="scope">
                    <el-button type="text" @click="getName(scope.row)">选择</el-button>
                  </template>
                </el-table-column>
              </el-table>
              <XPagination ref="pageInfo" :total="total" :get-data="getList" />
            </el-card>
          </el-row>
        </el-col>
      </el-row>
    </el-card>
  </div>
</template>

<script>
import XPagination from "./xpagination/XPagination";
import * as expertInfo from "../api/expertInfo"

export default {
  name: "list",
  components: { XPagination },
  data () {
    return {
      searchForm: {

      },
      tableData: [],
      loading: false,
      dialogVisible: false,
      total: 0,
      form: {
      },
      editStatus: "add",
    }
  },
  methods: {
    getList (pageInfo) {
      const param = {
        ...this.searchForm,
        ...pageInfo,
        roleName: this.activeName
      }
      expertInfo.queryByPage(param).then(response => {
        console.log(response)
        this.tableData = response.data.data.rows
        this.total = response.data.data.total
        this.loading = false
      }).catch(error => {
        console.log(error)
      })
    },
    handleSearch () {
      this.$refs.pageInfo.loadData()
    },
    getName (row) {
      this.$emit('getName', row)
    },
  },
  mounted () {
    this.handleSearch()
  }
}
</script>

<style scoped lang="scss"></style>
